package com.huike.clues.mapper;

import com.huike.common.core.domain.entity.SysDept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SysDeptMapper {

    List<SysDept> list(@Param("deptName") String deptName, @Param("status") String status);

    @Select("select ancestors from sys_dept where dept_id=#{parentId}")
    String findancestors(Long parentId);

    Integer save(SysDept sysDept);

    void update(SysDept sysDept);

    @Select("select * from sys_dept where dept_id=#{deptId}")
    SysDept findById(Long deptId);

    @Update("update sys_dept set del_flag=2 where dept_id=#{deptId}")
    Integer deleteById(Long deptId);

    @Select("select dept_id from sys_role_dept where role_id=#{roleId}")
    List<Integer> findDeptIds(Long roleId);
     //SysDeptMapper文件
    @Select("select parent_id from sys_dept")
    List<Long> findParentId();
    @Select("SELECT * FROM `sys_dept` where del_flag=0 and ancestors like CONCAT('%',#{deptId},'%')")
    List<SysDept> findByIancestors(Long deptId);

}
